<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-L-admin1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layui/css/formSelects-v4.css" media="all">
    <link rel="shortcut icon" href="../../statics/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="../../statics/css/font.css">
    <link rel="stylesheet" href="../../statics/css/xadmin.css">
    <script src="../../statics/js/jquery.min.js"></script>
    <script type="text/javascript" src="../../statics/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../statics/js/xadmin.js"></script>
</head>

<body>
<div class="x-body">
    <form class="layui-form" lay-filter="userModifyForm">
        <div class="layui-form-item" style="display: none">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>id
            </label>
            <div class="layui-input-inline">
                <input type="text" id="id" name="id" required
                       autocomplete="off" value="" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>用户名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="username" name="username" required lay-verify="required"
                       autocomplete="off" value="" disabled class="layui-input layui-disabled" readonly="readonly">
            </div>
        </div>


        <div class="layui-form-item">
            <label for="phone" class="layui-form-label">
                <span class="x-red">*</span>手机
            </label>
            <div class="layui-input-inline">
                <input type="text" value="" id="phone" name="phone" required lay-verify="phone"
                       autocomplete="off" disabled class="layui-input layui-disabled">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="email" class="layui-form-label">
                <span class="x-red">*</span>邮箱
            </label>
            <div class="layui-input-inline">
                <input type="text" value="" id="email" name="email" required lay-verify="email"
                       autocomplete="off" disabled class="layui-input layui-disabled">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="userNo" class="layui-form-label">
                <span class="x-red">*</span>学号
            </label>
            <div class="layui-input-inline">
                <input type="text" value="" id="userNo" name="userNo" required lay-verify="number"
                       autocomplete="off" disabled class="layui-input layui-disabled">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"> <span class="x-red">*</span>用户角色</label>
            <div class="layui-input-inline" style="width: 300px">
                <select disabled class="layui-disabled" name="roleIds" id="roles_add" xm-select="roles3" xm-select-direction="down">
                </select>
            </div>
        </div>
    </form>
</div>
<script>
    layui.config({
        base: '../../layui/lay/modules/'
    }).extend({
        formSelects: 'formSelects-v4'
    });

    layui.use(['form', 'layer', 'formSelects'], function () {

        var formSelects = layui.formSelects;
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;

    });

    $.post("/role/getAllRole", function (result) {
        if (result.code === 0) {
            for (var i = 0; i < result.data.length; i++) {
                var opt = $("<option></option>").appendTo("#roles_add");
                opt.text(result.data[i].roleName).val(result.data[i].id);
            }
            setTimeout(function () {
                /*渲染当前登录用户的角色*/
                $.ajax({
                    url: "/role/getAllRoleByLoginUserId",
                    success: function (result) {
                        debugger;
                        var roleArray = new Array();
                        for (var i = 0; i < result.data.length; i++) {
                            roleArray.push(result.data[i].id);
                        }
                        layui.formSelects.value('roles3', roleArray);
                    }
                });
                /*渲染当前的登录用户的个人信息*/
                $.ajax({
                    url: "/user/getUserInfoById",
                    success: function (result) {
                        debugger;
                        if (0 == result.code) {
                            $("#username").val(result.data.username);
                            $("#phone").val(result.data.phone);
                            $("#email").val(result.data.email);
                            $("#userNo").val(result.data.userNo);
                        }
                    }
                })
            }, 200);
            layui.formSelects.render();
        }
    });

</script>
</body>

</html>